package com.xian.daoimpl;

import java.util.List;

import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.xian.dao.OrderDao;
import com.xian.domain.Greens;
import com.xian.domain.Order;
import com.xian.domain.Sell;

public class OrderDaoImpl extends HibernateDaoSupport implements OrderDao{


	@Override
	public void addupOrder(Order order) {
		this.getHibernateTemplate().save(order);
		
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Order> findOrderPage(int pages) {
		Object[] objects ={(pages-1)*Greens.PANGESIZE,Greens.PANGESIZE};
		return getHibernateTemplate().find("from Order ");
	}

	@Override
	public int findOrdercount() {
		int n = 0;
		Query query = this.getSession().createQuery("select count(*) from Order");
		 n = new Integer(((Long) query.uniqueResult()).toString());
		return n;
		}

	@Override
	public List<Order> findOrderSort(String hql) {
		
		return getHibernateTemplate().find(hql);
	}

	@Override
	public void updateOrder(Order order) {
		
		this.getHibernateTemplate().update(order);
		
	}

	@Override
	public void deleteOrder(Order order) {
		// TODO Auto-generated method stub
		this.getHibernateTemplate().delete(order);
	}

	

}
